clear all

import delimited "cohort2_public_0-48m_5.18.23.csv"

rename public_id id


rename q8surveyyear year
rename q8surveymonth month
rename q8weight_p person_weight
rename q8weight_pu poverty_weight

gen own_rent = q8a1
label define ownlabel 1 "Rent" 2 "Own" 3 "live with family, pay part rent" 4 "live with family, pay no rent" 5 "rent a room, not form family" 6 "live in apt/house owned by other" 7 "live in temporary housing" 8 "live on street or park" 9 "other arrangement"
label val own_rent ownlabel
replace own_rent = . if own_rent > 9
order own_rent, after(q8a1)
drop q8a1

gen homeowner = 0 if own_rent !=2
replace homeowner = 1 if own_rent ==2
lab define ownlab 0 "No" 1 "Yes"
lab val homeowner ownlab

gen renter=0 if own_rent !=1 | own_rent !=4 | own_rent !=5
replace renter=1 if own_rent ==1 | own_rent==4 | own_rent==5
lab define rentlab 0 "No" 1 "Yes"
lab val renter rentlab
order homeowner renter, after(own_rent)

gen gender = q8a3_gender
label define genderlabel 1 "male" 2 "female"
label val gender genderlabel
replace gender = . if gender==97
gen male =0 if gender !=1
replace male=1 if gender==1
gen female =0 if gender !=2
replace female =1 if gender ==2
drop q8a3_gender
order gender male female, after(renter)

rename q8a3_age_tc age
replace age = . if age ==999

rename q8a4 others_inhome1
replace others_inhome1 = . if others_inhome1 > 2
rename q8a4_rel1 others_relation1
replace others_relation1 =. if others_relation1==97
rename q8a4_age1_tc others_age1
replace others_age1=. if others_age1==977
rename q8a4_gender1 others_gender1
replace others_gender1 = . if others_gender1==97


rename q8a4_rel2 others_relation2
replace others_relation2 =. if others_relation2==97
rename q8a4_age2_tc others_age2
replace others_age2=. if others_age2==977
rename q8a4_gender2 others_gender2
replace others_gender2 = . if others_gender2==97

rename q8a4_rel3 others_relation3
replace others_relation3 =. if others_relation3==97
rename q8a4_age3_tc others_age3
replace others_age3=. if others_age3==977
rename q8a4_gender3 others_gender3
replace others_gender3 = . if others_gender3==97

rename q8a4_rel4 others_relation4
replace others_relation4 =. if others_relation4==97
rename q8a4_age4_tc others_age4
replace others_age4=. if others_age4==977
rename q8a4_gender4 others_gender4
replace others_gender4 = . if others_gender4==97

rename q8a8x_tc monthly_rent
rename q8a9a rent_controlled
rename q8a10x_tc monthly_mortgage

gen monthly_rent_mortgage = monthly_rent if monthly_rent !=.
replace monthly_rent_mortgage = monthly_mortgage if monthly_mortgage !=.
replace monthly_rent_mortgage = 0 if own_rent ==4

rename q8a11 bedrooms
rename q8b1 neighborhood_rating
replace neighborhood_rating =. if neighborhood_rating > 5
rename q8b2 nyc_rating
replace nyc_rating =. if nyc_rating > 5

rename q8c1 freefood
recode freefood (2=0) 
lab define foodlab 0 "No" 1 "Yes"
label val freefood foodlab
replace freefood =. if freefood > 2

rename q8c2 freefood_howoften
replace freefood_howoften =. if freefood_howoften > 5

rename q8c3 homeless_facility
recode homeless_facility (2=0)
lab define faclabel 0 "No" 1 "Yes"
lab val homeless_facility faclabel
drop if homeless_facility > 2

rename q8c4x homeless_facility_nights

/*
rename qc5_1 assist_jobtrain
rename qc5_2 assist_educ
rename qc5_3 assist_housing
rename qc5_4 assist_finances
rename qc5_5 assist_obtainingbenefits
rename qc5_6 assist_healthservices
rename qc5_7 assist_counseling
rename qc5_8 assist_childcare
rename qc5_9 assist_parenting
rename qc5_10 assist_legal
rename qc5_11 assist_mentoring
rename qc5_12 assist_else

rename q8c6 visit_communityorg_times
replace visit_communityorg_times =. if visit_communityorg_times > 6
*/

rename q8d1 generalhealth_rating
replace generalhealth_rating = . if generalhealth_rating > 5
recode generalhealth_rating (5=1) (4=2) (2=4) (1=5)
lab define healthlab 1 "Poor" 2 "Fair" 3 "Good" 4 "Very Good" 5 "Excellent"
label val generalhealth_rating healthlab

rename q8d1_sp spousehealth_rating
replace spousehealth_rating = . if spousehealth_rating > 5
recode spousehealth_rating (5=1) (4=2) (2=4) (1=5)
lab define shealthlab 1 "Poor" 2 "Fair" 3 "Good" 4 "Very Good" 5 "Excellent"
label val spousehealth_rating shealthlab

rename q8d2 disability_preventwork
recode disability_preventwork (2=0)
lab define dislab 0 "No" 1 "Yes"
label val disability_preventwork dislab
replace disability_preventwork = . if disability_preventwork > 2

rename q8d2 spouse_preventwork
recode spouse_preventwork (2=0)
lab define sdislab 0 "No" 1 "Yes"
label val spouse_preventwork sdislab
replace spouse_preventwork = . if spouse_preventwork > 2

rename q8d7_1 depressed_howoften
rename q8d7_2 nervous_howoften
rename q8d7_3 restless_howoften
rename q8d7_4 hopeless_howoften
rename q8d7_5 effort_howoften
rename q8d7_6 worthless_howoften
/*
rename qd3 depressed_2weeks
recode depressed_2weeks (2=0)
lab define deplab 0 "No" 1 "Yes"
label val depression deplab
replace depression=. if depression >2

rename qd4 stressed_anxious_1month
recode stressed_anxious_1month (2=0)
lab define stresslab 0 "No" 1 "Yes"
label val stress stresslab
replace stress=. if stress >2
*/

rename q4d5 money_worries_howoften
recode money_worries_howoften (4=1) (3=2) (2=3) (1=4)
lab define moneylab 1 "Never" 2 "Rarely" 3 "Sometimes" 4 "Often"
label val money_worries moneylab
replace money_worries =. if money_worries > 4

rename q8d6 life_rating_0_10
replace life_rating_0_10 =. if life_rating_0_10 > 10

rename q8f1 food_insufficient
replace food_insufficient = . if food_insufficient > 4

rename q8f2 food_runout_worry
recode food_runout_worry (1=3) (3=1)
lab define worrylabel 1 "Never" 2 "Sometimes" 3 "Often"
label val food_runout_worry worrylabel
replace food_runout_worry =. if food_runout_worry > 3

rename q8f3 food_ranout
recode food_ranout (1=3) (3=1)
lab define ranoutlabel 1 "Never" 2 "Sometimes" 3 "Often"
lab val food_ranout ranoutlabel
replace food_ranout =. if food_ranout > 3

rename q8f4 rent_hardship
recode rent_hardship (2=0) (3=0)
lab define renthlab 0 "No" 1 "Yes"
lab val rent_hardship renthlab
replace rent_hardship = . if rent_hardship > 3

rename q8f5 moved_finances
recode moved_finances (2=0)
lab define movlab 0 "No" 1 "Yes"
lab val moved_finances movlab
replace moved_finances =. if moved_finances > 2

rename q8f6 moved_temporary
recode moved_temporary (2=0)
lab def movetmplab 0 "No" 1 "Yes"
lab val moved_temporary movetmplab
replace moved_temporary =. if moved_temporary > 1

rename q8f7 energy_bill
recode energy_bill (2=0)
lab def enlab 0 "No" 1 "Yes"
lab val energy_bill enlab
replace energy_bill =. if energy_bill > 1

rename q8f8 disconnected
recode disconnected (2=0)
lab def discolab 0 "No" 1 "Yes"
lab val disconnected discolab
replace disconnected =. if disconnected >1

rename q8f9 skipped_healthcare
recode skipped_healthcare (2=0)
lab def skiplab 0 "No" 1 "Yes"
lab val skipped_healthcare skiplab
replace skipped_healthcare =. if skipped_healthcare > 1

rename q8f10 ranout_money
recode ranout_money (3=1) (1=3)
lab def ranlab 1 "Never" 2 "Sometimes" 3 "Often"
label val ranout_money ranlab
replace ranout_money =. if ranout_money > 3

/*
imp_q8hous1 = didn't pay full amount of rent/mortgage
imp_q8hous2 = moved w/ someone else because of finances
imp_q8hous3 = moved temporraily
imp_q8bill1 = energy bill
imp_q8bill2 = disconnected
imp_q8medic1 = couldn't go to doctor because of cost
imp_q8financ1 = how often run out of money
imp_q8food1 = food insufficient
imp_q8food2 = food runout worry
imp_q8food3 = food ranout
imp_q8bor = borough
imp_qsnapeyes = Foodstamps/SNAP last 12 mos
imp_qretyes = retirement income last 12 mos
imp_qdisyes = disability income last 12 mos
imp_welfyes = public/cash assistance or welfare last 12 mos
imp_quiyes = unemployment compensation last 12 most
imp_qregyes = regular $ assistance from someone outside the home
imp_qothyes = other income/benefits not mentioned
imp_q8health = general health rating
imp_q8foodindom = food hardship indicator (moderate) last 12 months
imp_q8houseindmod = housing hardship indicator (moderate) last 12 mos
imp_q8billindmod = bill/utility hardship indicator (moderate) last 12 mos
imp_q8financindmod = financial hardship indicator (moderate) last 12 mos
imp_q8foodindsev = food hardship indicator (severe) last 12 mos
imp_q8billindsev = billing hardshpi indicator (severe) last 12 mos
imp_q8medichard = medical hardship indicator last 24 months (?)
imp_q8financindsv = financial hardhspi indicator (severe) last 12 mos
severe_hardship = presence of a severe material hardhspi
*/

rename imp_q8hous1 imp_rent_hardship
recode imp_rent_hardship (2=0)
lab define imprenthlab 0 "No" 1 "Yes"
lab val imp_rent_hardship imprenthlab

rename imp_q8hous2 imp_moved_finances
recode imp_moved_finances (2=0)
lab define movfin 0 "No" 1 "Yes"
lab val imp_moved_finances movfin

rename imp_q8hous3 imp_moved_temporary
recode imp_moved_temporary (2=0)
lab define impmovtemplab 0 "No" 1 "Yes"
label val imp_moved_temporary impmovtemplab

rename imp_q8bill1 imp_energy_bill
recode imp_energy_bill (2=0)
label define impbilllab 0 "No" 1 "Yes"
label val imp_energy_bill impbilllab

rename imp_q8bill2 imp_disconnected
recode imp_disconnected (2=0)
label define impdisclab 0 "No" 1 "Yes"
label val imp_disconnected impdisclab

rename imp_q8medic1 imp_skipped_healthcare
recode imp_skipped_healthcare (2=0)
label define impskiplab 0 "No" 1 "Yes"
label val imp_skipped_healthcare impskiplab

rename imp_q8financ1 imp_ranout_money
recode imp_ranout_money (3=1) (1=3)
lab def impranlab 1 "Never" 2 "Sometimes" 3 "Often"
label val imp_ranout_money impranlab

rename imp_q8food1 imp_food_insufficient

rename imp_q8food2 imp_food_runout_worry
recode imp_food_runout_worry (1=3) (3=1)
lab define impworrylabel 1 "Never" 2 "Sometimes" 3 "Often"
label val imp_food_runout_worry impworrylabel

rename imp_q8food3 imp_food_ranout
recode imp_food_ranout (1=3) (3=1)
lab define impranoutlabel 1 "Never" 2 "Sometimes" 3 "Often"
lab val imp_food_ranout impranoutlabel

rename imp_qbor borough

rename imp_q8snapyes imp_snap_12mos
recode imp_snap_12mos (2=0)
lab define impsnaplab 0 "No" 1 "Yes"
lab val imp_snap_12mos impsnaplab

rename imp_q8retyes imp_retirement_12mos
recode imp_retirement_12mos (2=0)
lab define impretlab 0 "No" 1 "Yes"
lab val imp_retirement_12mos impretlab

rename imp_q8disyes imp_disability_12mos
recode imp_disability_12mos (2=0)
lab define impdislab 0 "No" 1 "Yes"
lab val imp_disability_12mos impdislab

rename imp_q8welfyes imp_welfare_12mos
recode imp_welfare_12mos (2=0)
lab define impwelflab 0 "No" 1 "Yes"
lab val imp_welfare_12mos impwelflab

rename imp_q8uiyes imp_unemployment_12mos
recode imp_unemployment_12mos (2=0)
lab define impumplab 0 "No" 1 "Yes"
lab val imp_unemployment_12mos impumplab

rename imp_q8regyes imp_regcashassist_12mos
recode imp_regcashassist_12mos (2=0)
lab define impregcashlab 0 "No" 1 "Yes"
lab val imp_regcashassist_12mos impregcashlab

rename imp_q8othyes imp_otherbenefits
recode imp_otherbenefits (2=0)
lab define impotherlab 0 "No" 1 "Yes"
lab val imp_otherbenefits impotherlab

rename imp_q8health imp_genhealth_rating

rename imp_q8foodindmod foodhardship_moderate
recode foodhardship_moderate (2=0)
lab define modfoodhardship 0 "No" 1 "Yes"
lab val foodhardship_moderate modfoodhardship

rename imp_q8houseindmod househardship_moderate
recode househardship_moderate (2=0)
lab define hhhardshiplab 0 "No" 1 "Yes"
lab val househardship_moderate hhhardshiplab

rename imp_q8billindmod energyhardship_moderate
recode energyhardship_moderate (2=0)
lab define ehardshiplab 0 "No" 1 "Yes"
lab val energyhardship_moderate ehardshiplab

rename imp_q8financindmod financialhardship_moderate
recode financialhardship_moderate (2=0)
lab define finhardshiplab 0 "No" 1 "Yes"
lab val financialhardship_moderate finhardshiplab

rename imp_q8foodindsev foodhardship_severe
recode foodhardship_severe (2=0)
lab define foodhardsevlab 0 "No" 1 "Yes"
lab val foodhardship_severe foodhardsevlab

rename imp_q8houseindsev househardship_severe
recode househardship_severe (2=0)
lab define househardsevlab 0 "No" 1 "Yes"
label val househardship_severe househardsevlab


rename imp_q8billindsev energyhardship_severe
recode energyhardship_severe (2=0)
lab define ehardshipsevlab 0 "No" 1 "Yes"
lab val energyhardship_severe ehardshipsevlab

rename imp_q8medichard medicalhardship_24mos
recode medicalhardship_24mos (2=0)
lab define medhardshiplab 0 "No" 1 "Yes"
lab val medicalhardship_24mos medhardshiplab

rename imp_q8financindsev financialhardship_severe
recode financialhardship_severe (2=0)
lab define finhardseverelab 0 "No" 1 "Yes"
lab val financialhardship_severe finhardseverelab

/*
rename q8g0 workedforpay_lastweek
recode workedforpay_lastweek (2=0)
lab def workedpaylab 0 "No" 1 "Yes"
lab val workedforpay_lastweek workedpaylab
replace workedforpay_lastweek =. if workedforpay_lastweek > 2

rename q8g3 spouseworked_lastweek
recode spouseworked_lastweek (2=0)
lab def spouseworklab 0 "No" 1 "Yes"
lab val spouseworked_lastweek spouseworklab
replace spouseworked_lastweek = . if spouseworked_lastweek > 2
*/

rename q8h5_6 wic_12mos
recode wic_12mos (2=0)
lab def wiclab 0 "No" 1 "Yes"
lab val wic_12mos wiclab
replace wic_12mos = . if wic_12mos > 2

rename q8h5_7 houseassist_12mos
recode houseassist_12mos (2=0)
lab def houseaslab 0 "No" 1 "Yes"
lab val houseassist_12mos houseaslab
replace houseassist_12mos = . if houseassist_12mos > 2

rename q8h5_8 medicaid_12mos
recode medicaid_12mos (2=0)
lab def medlab 0 "No" 1 "Yes"
lab val medicaid_12mos medlab
replace medicaid_12mos = . if medicaid_12mos > 2

rename qi3 internet_access
rename qi4 inter_access_mobile

rename qchildx_tc children_under18
rename q8adultx_tc hh_adults
rename qpersonx_tc hh_size

rename imp_race race
gen white = 0 if race !=1
replace white = 1 if race==1
gen black = 0 if race !=2
replace black=1 if race==2
gen asian=0 if race !=3
replace asian=1 if race==3
gen race_other=0 if race !=4
replace race_other=1 if race==4
gen hispanic=0 if race !=5
replace hispanic=1 if race==5

rename imp_educat educ
rename imp_q8moswork months_worked
rename imp_q8smoswork spousemonths_worked

rename q8sevhard severe_hardship
recode severe_hardship (2=0)
lab def hardlab 0 "No" 1 "Yes"
lab val severe_hardship hardlab

rename q8frsl freelunch_amount
rename q8wicval wic_amount

rename imp_q8earnhd_tc earnings
rename imp_q8earnsp_tc spouse_earnings
rename imp_q8incret_tc retirement_earnings
rename imp_q8incdis_tc disability_income
rename imp_q8incwelf_tc welfare_income
rename imp_q8incui_tc unemployment_income
rename imp_q8incsnap_tc snap_income
rename q8fiitax_tc federal_taxes
rename q8siitax_tc state_taxes
rename q8fica_tc fica_taxes
rename q8spmpov spm_poverty_status
recode spm_poverty_status (2=0)
lab def spmlab 0 "No" 1 "Yes"
lab val spm_poverty_status spmlab
/*
rename q8b3 physicalhealth_rating
recode physicalhealth_rating (1=5) (2=4) (4=2) (5=1)
lab def physlab 1 "Poor" 2 "Fair" 3 "Good" 4 "Very Good" 5 "Excellent"
lab val physicalhealth_rating physlab
replace physicalhealth_rating = . if physicalhealth_rating > 5

rename q8b4 mentalhealth_rating
recode mentalhealth_rating (1=5) (2=4) (4=2) (5=1)
lab def mentlab 1 "Poor" 2 "Fair" 3 "Good" 4 "Very Good" 5 "Excellent"
lab val mentalhealth_rating mentlab
replace mentalhealth_rating = . if mentalhealth_rating > 5
*/
drop q*
gen wave=3

save wave3.dta, replace